package com.corex.vinayak;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.zip.Inflater;

import com.corex.utils.Constants;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.CalendarView;
import android.widget.CalendarView.OnDateChangeListener;
import android.widget.Toast;

public class TimetableActivity extends Activity {
	
	
	CalendarView timeTableCalendar;
	String selectedDate = "";
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.timetable_calendar);
		
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
		Date date = new Date();
		selectedDate = simpleDateFormat.format(date);
		
		Toast.makeText(getBaseContext(), selectedDate, Toast.LENGTH_SHORT).show();
		
		timeTableCalendar = (CalendarView) findViewById(R.id.timetable_calendar);
		timeTableCalendar.setOnDateChangeListener(new OnDateChangeListener() {

			@Override
			public void onSelectedDayChange(CalendarView view, int year,
					int month, int dayOfMonth) {
				selectedDate = year+"-"+month+"-"+dayOfMonth;
				Toast.makeText(getBaseContext(), selectedDate, Toast.LENGTH_SHORT).show();
			}
		});
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		MenuInflater inflater = getMenuInflater();
	    inflater.inflate(R.menu.timetable_view_detail_menu, menu);
		return true;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		Intent intent = new Intent(TimetableActivity.this, TimeTableDetailsActivity.class);
		intent.putExtra(Constants.TIMETABLE_SELECTED_DATE, selectedDate);
		startActivity(intent);
		return true;
	}
}
